package com.gems.model;


import java.util.List;

import org.hibernate.Session;

import com.gems.util.HibernateUtil;
 
public class App 
{
    public static void main( String[] args )
    {
		System.out.println("Maven + Hibernate + MySQL");
		Session session = HibernateUtil.getSessionFactory().openSession();

		// now lets pull events from the database and list them
		session.beginTransaction();
		List result = session.createQuery("from Stock").list();
		for (Stock stock : (List<Stock>) result) {
			System.out.println("stock:" + stock.getStockId() + ":"
					+ stock.getStockCode() + ":" + stock.getStockName());
		}
		session.getTransaction().commit();
		session.close();
		/*
		 * session.beginTransaction(); Stock stock = new Stock();
		 * 
		 * stock.setStockCode("6081"); stock.setStockName("ANSAUI");
		 * 
		 * session.save(stock); session.getTransaction().commit();
		 */
    }
}